package com.example.view.activity;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.example.common.base.AbsActivity;
import com.example.view.R;
import com.example.view.databinding.ActViewHistoryMenuBinding;

import java.util.ArrayList;
import java.util.List;

/**
 * Warp LinearLayout:搜索历史
 */
@Route(path = "/activity/historyMenu")
public class HistoryMenuActivity extends AbsActivity<ActViewHistoryMenuBinding> implements View.OnClickListener {

    private List<String> systemLabel;

    @Override
    protected int getLayoutId() {
        return R.layout.act_view_history_menu;
    }

    @Override
    protected void main() {
        systemLabel = new ArrayList<>();
        systemLabel.add("lotus挖矿系统");
        systemLabel.add("分布式存储计算引擎");
        systemLabel.add("资源管理系统");
        systemLabel.add("网络资源管理平台");
        systemLabel.add("计算资源服务引擎");
        systemLabel.add("存储资源管理系统");
        scrollViewLayout(systemLabel);
    }

    private void scrollViewLayout(List<String> data) {
        mBinding.historyMenu.removeAllViews();
        LayoutInflater layoutInflater = LayoutInflater.from(mContext);
        if (data != null && data.size() > 0) {
            for (int i = 0; i < data.size(); i++) {
                View view = layoutInflater.inflate(R.layout.item_view_history_menu, mBinding.historyMenu, false);
                TextView text = view.findViewById(R.id.tv_text);
                text.setText(data.get(i));
                text.setTag(i);
                text.setOnClickListener(HistoryMenuActivity.this);
                mBinding.historyMenu.addView(view);
            }
        }
    }

    @Override
    protected void initListener() {

    }

    @Override
    public void onClick(View v) {
        int position = (int) v.getTag();
        Toast.makeText(this, systemLabel.get(position), Toast.LENGTH_SHORT).show();
    }
}
